<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<%@ page import="com.scalar.chiptrack.sales.forms.quote.ApproverQuotationForm,com.scalar.chiptrack.utils.ConfigManager"%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String quotationId = request.getParameter("quotationId");
    String closeWindowAfterSessionTimeOut = ( String ) request.getAttribute( "closeWindowAfterSessionExp" );
%>

<%
    ApproverQuotationForm approverQuotationForm = (ApproverQuotationForm) request.getAttribute("approverQuotationForm");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html:html>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<style type="text/css">
a { text-decoration : none}
</style>
<script language="javaScript">
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}
function sendMail(salesOrderId)
{
   window.open ('<%=chipTracContext%>/sendAckMail.do?salesOrderId=' + salesOrderId , 'sendMailPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
}
</script>
</HEAD>
<%
 if ( ! approverQuotationForm.getQuotation().isApproved() )
    { %>
           <BODY background="<%=chipTracContext%>/jsp/includes/images/not_approved_icon.gif" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<%
    }
    else
    {
%>

        <BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<%
    }
%>
<%
if ( closeWindowAfterSessionTimeOut == null )
{
%>
<html:form name="approverQuotationForm" action="/approveQuotation" method="post" type="com.scalar.chiptrack.sales.forms.ApproverQuotationForm">
<p STYLE="page-break-after: always">
<nested:nest property="quotation">
<table width="98%" cellspacing='0' cellpadding='0' border="0" align=center>
    <tr>
        <td width="35%" align="left" valign="top"><img src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" height="72" width='180' border=0></td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td widht="27%" align="center" class="NArialL">
            <table border=0 cellspacing='0' cellpadding='0'>
                <tr><td align="center"><h2><bean:message key="label.sales.quotation.quoteDetails"/></h2></td></tr>
                <tr><td align="center" class="NArialL"><nested:write name="quotation" property="clientName"/></td></tr>
                <tr><td align="center" class="NArialL"><nested:write name="quotation" property="clientAddressAsHTML" filter="false"/></td></tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td width="36%" align=right valign="top">
            <font class="NArialW">
                <table width='80' align=right border='0' <%--background='<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif'--%>>
                    <tr>
                        <td>
                            <a href="javascript:window.print();" title='Click here to Print Quotation Details'><img src="<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif" width='80' border="0" alt="Click here to Print Quotation Details"></a>
                        </td>
                    </tr>
                </table>
                <br>
                <table border ="0" width='5' align=left <%--background='<%=chipTracContext%>/jsp/includes/images/email1.gif'--%>>
                    <tr><td>&nbsp;</td></tr>
                </table>
            </font>
        </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <tr>
        <td colspan="5" width="100%">
            <table border="0" width="100%">
                <tr>
                    <td height="100%" width="33%">
                        <table border=1 width="100%" height="100%"bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td class="NArialL" bgcolor="#DEE1E2"><bean:message key="label.sales.quotation.orderedBy"/> :</td></tr>
                            <tr height=20><td  valign="top" class="NArialL" bgcolor="#FFFFEE">
                                <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                                    <tr><td><nested:write name="quotation" property="billingAddressAsHTML" filter="false"/></td></tr>
                                </table></td>
                            </tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td height="100%" width="30%">
                        <table border=1 width="100%" height="100%"bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td class="NArialL" bgcolor="#DEE1E2">Bill To :</td></tr>
                            <tr height=20><td class="NArialL"valign="top" bgcolor="#FFFFEE">
                                <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                                    <tr><td><nested:write name="quotation" property="billingAddressAsHTML" filter="false"/></td></tr>
                                </table></td>
                            </tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td height="100%" width="38%">
                        <table border=1 width="100%" height="100%" bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td class="NArialL" bgcolor="#DEE1E2">Ship To :</td></tr>
                            <tr height=20><td class="NArialL"valign="top" bgcolor="#FFFFEE">
                                <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                                     <tr><td><nested:write name="quotation" property="shippingAddressAsHTML" filter="false"/></td></tr>
                                </table></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <tr>
        <td colspan="5" width="100%">
            <table border="0" width="100%">
                <tr>
                    <td height="100%" width="33%">
                        <table width="100%" height="100%"class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td bgcolor='#DEE1E2'> Quote #</td></tr>
                            <tr height=20>
                                <td bgcolor='#FFFFEE'><nested:write property="quotationNo" />&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td height="100%" width="30%">
                        <table width="100%" height="100%"class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td bgcolor='#DEE1E2'> <bean:message key="label.sales.quotation.orderDate"/> </td><td bgcolor='#DEE1E2'>Ship Via</td></tr>
                            <tr height=20><td bgcolor='#FFFFEE'><nested:write name="quotation" property="quotationDate"/>&nbsp;</td>
                            <td bgcolor='#FFFFEE'>&nbsp;
                            <nested:notEqual property="shippingAccount" value="-1">
                                <nested:write property="shippingAccount"/>
                            </nested:notEqual></td></tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td height="100%" width="38%">
                        <table width="100%"height='100%' class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
                            <tr height=20><td  bgcolor='#DEE1E2'><bean:message key="label.sales.quotation.salesPerson"/></td><td bgcolor='#DEE1E2'><bean:message key="label.sales.quotation.regionalRep"/></td><td bgcolor='#DEE1E2'> Del Terms</td><td bgcolor='#DEE1E2'>Pay Terms</td></tr>
                            <tr height=20>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="salesPerson" />&nbsp;
                                </td>
                                <td bgcolor='#FFFFEE'>
                                    &nbsp;<nested:write property="regionalRep"/>
                                </td>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="deliveryTerms"/>&nbsp;
                                </td>
                                <td bgcolor='#FFFFEE'>
                                   <nested:notEqual property="shippingTerms" value="-1">
                                        <nested:write property="shippingTerms"/>
                                   </nested:notEqual>&nbsp;
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
       </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <tr><td colspan=5 class='NArialL'><U>Comments:</U></td></tR>
    <tr>
       <td colspan="5" class='NArialL' bgcolor='#FFFFEE'>
        <nested:write property="comments"/>
       </td>
    </tr>
    </nested:nest>
    <tr><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <tr>
        <td colspan='5'>
            <% int additionalColumns = 0; %>
            <table width="100%" border="1" bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height="20">
                    <td width="8%" class="NArialL" bgcolor='#DEE1E2' align="center">PO Line#</td>
                    <td width="5%" class="NArialL" bgcolor='#DEE1E2' align="center">Req Qty</td>
                    <%
                        if(ConfigManager.isShowQuoteMinOrderQty()) {
                            additionalColumns++;
                    %>
                        <td width="5%" class="NArialL" bgcolor='#DEE1E2' align="center">Min Order Quantity</td>
                    <%
                        }
                    %>
                    <td width="2%" class="NArialL" bgcolor='#DEE1E2' align="center">UM</td>
                    <td width="13%" class="NArialL" bgcolor='#DEE1E2' align="center"><bean:message key="label.mfgPartNumber" /></td>
                    <td width="13%" class="NArialL" bgcolor='#DEE1E2' align="center"><bean:message key="label.customerPartNumber"/></td>
                    <td width="18%" class="NArialL" bgcolor='#DEE1E2' align="center">Description</td>
                    <td width="10%" class="NArialL" bgcolor='#DEE1E2' align="center">Req Dock Date</td>
                    <td width="8%" class="NArialL" bgcolor='#DEE1E2' align="center">Lead Time</td>
                    <td width="8%" class="NArialL" bgcolor='#DEE1E2' align="center">Taxable<br> Yes or No</td>
                    <nested:equal value="true" property="quotation.distributor">
                        <%
                            if ( ConfigManager.isShowQuoteRequestedPrice() )
                            {
                                additionalColumns++;
                        %>
                                <td width="5%" align="center" bgcolor="#DEE1E2" class="NArialL"><bean:message key="label.sales.requestedPrice"/></td>
                        <%
                            }
                            if ( ConfigManager.isShowQuoteCustResalePrice() )
                            {
                                additionalColumns++;
                        %>
                                <td width="5%" align="center" bgcolor="#DEE1E2" class="NArialL"><bean:message key="label.sales.customerResalePrice"/></td>
                        <%
                            }
                        %>
                    </nested:equal>
                    <td width="5%" class="NArialL" bgcolor='#DEE1E2' align=center><bean:message key="label.sales.price"/></td>
                    <nested:equal value="true" property="quotation.distributor">
                        <%
                            if ( ConfigManager.isShowQuoteSuggResalePrice() )
                            {
                                additionalColumns++;
                        %>
                                <td width="5%" align="center" bgcolor="#DEE1E2" class="NArialL"><bean:message key="label.sales.suggestedResalePrice"/></td>
                        <%
                            }
                        %>
                    </nested:equal>
                    <td width="11%" class="NArialL" bgcolor='#DEE1E2' align=center>Extended<br> Price</td>
                </tr>

                <% int j = 0; %>
                <logic:iterate id="myHashMap" name="lineItemsWithSubtotals">
                <logic:iterate id="lineItemList" name="myHashMap" >
                <logic:iterate id="LineItem" name="lineItemList" property="key" type="com.scalar.chiptrack.sales.LineItem">
                <tr height=20>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center><bean:write name="LineItem" property="poLineItemNo"/></td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center><bean:write name="LineItem" property="quantity"/></td>
                    <%
                        if(ConfigManager.isShowQuoteMinOrderQty()) {
                    %>
                        <td bgcolor='#FFFFEE' class="NArialL" align=center><bean:write name="LineItem" property="minOrderQty"/></td>
                    <%
                        }
                    %>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center>ea</td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap><bean:write name="LineItem" property="manufacturingPartNo"/></td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                        <logic:equal value="-2" name="LineItem" property="customerPartNo">
                            <bean:write name="LineItem" property="newCustomerPartNo"/>
                        </logic:equal>
                        <logic:notEqual value="-2" name="LineItem" property="customerPartNo">
                            <bean:write name="LineItem" property="customerPartNo"/>
                        </logic:notEqual>&nbsp;</td>
                    <td bgcolor='#FFFFEE' class="NArialL" ><bean:write name="LineItem" property="lineItemDescription"/>&nbsp;</td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center><bean:write name="LineItem" property="requestDate"/>&nbsp;</td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center>
                        <logic:notEqual value="0" name="LineItem" property="leadTime">
                            <bean:write name="LineItem" property="leadTime"/>
                        </logic:notEqual>
                        &nbsp;</td>
                    <td bgcolor='#FFFFEE' class="NArialL" align=center><bean:write name="LineItem" property="isTaxableAsString"/>&nbsp;</td>
                    <nested:equal value="true" property="quotation.distributor">
                        <%
                            if ( ConfigManager.isShowQuoteRequestedPrice() )
                            {
                        %>
                                <td bgcolor="#FFFFEE" class="NArialL" align=right><bean:write name="LineItem" property="reqPriceAsString"/></td>
                        <%
                            }
                            if ( ConfigManager.isShowQuoteCustResalePrice() )
                            {
                        %>
                                <td bgcolor="#FFFFEE" class="NArialL" align=right><bean:write name="LineItem" property="custResaleAsString"/></td>
                        <%
                            }
                        %>
                    </nested:equal>
                    <td bgcolor='#FFFFEE' class="NArialL" align=right><bean:write name="LineItem" property="unitPriceAsString"/>&nbsp;</td>
                    <nested:equal value="true" property="quotation.distributor">
                        <%
                            if ( ConfigManager.isShowQuoteSuggResalePrice() )
                            {
                        %>
                                <td bgcolor="#FFFFEE" class="NArialL" align=right><bean:write name="LineItem" property="suggResaleAsString"/></td>
                        <%
                            }
                        %>
                    </nested:equal>
                    <td bgcolor='#FFFFEE' class="NArialL" align=right><bean:write name="LineItem" property="extendedPriceForQuoteAsString"/>&nbsp;</td>
                </tr>
                <%j++;%>
                </logic:iterate>
                <tr height="20">
                    <td bgcolor="#FFFFFF" class="NArialL" align="right">
                        Sub Total
                        <bean:define id="subTotal" name="lineItemList" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>
                    </td>
                    <td bgcolor="#FFFFFF" class="NArialL" align="center">
                        <bean:write name="subTotal" property="subTotalQty" />
                    </td>
                    <td colspan="<%=(8+additionalColumns)%>">&nbsp;</td>
                    <td bgcolor="#FFFFFF" class="NArialL" align="right">
                        <bean:write name="subTotal" property="subTotalAmt" />&nbsp;
                    </td>
                </tr>
                </logic:iterate>
                </logic:iterate>
            </table>
        <% if (j == 0){%>
        <font class="NArialL"><li>All the line items have been cancelled.</font>
        <%}%>
        </td>
    </tr>
    <tr><td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <nested:nest property="quotation">
    <tr>
        <td valign="top" align="left" width="35%">
            <table width="90%" border="1" align=left bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr>
                   <%--<logic:equal value="-2" name="QuotationForm" property="endCustomerId">
                        <td class='NArialL' bgcolor='#DEE1E2'> New <bean:message key="label.sales.endUser"/> </td>
                    </logic:equal>--%>
                    <logic:notEqual value="-2" name="QuotationForm" property="endCustomerId">
                          <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.endUser"/> </td>
                    </logic:notEqual>
                    <%--<logic:equal value="-2" name="QuotationForm" property="odmId">
                        <td class='NArialL' bgcolor='#DEE1E2'> New <bean:message key="label.sales.shipToCustomer"/> </td>
                    </logic:equal>--%>
                    <logic:notEqual value="-2" name="QuotationForm" property="odmId">
                        <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.shipToCustomer"/></td>
                    </logic:notEqual>
                 </tr>
                <tr>
                    <%--<logic:equal value="-2" name="QuotationForm" property="endCustomerId">
                        <td class='NArialL' bgcolor='#FFFFEE'><bean:write name="QuotationForm" property="newEndUserName"  /></td>
                    </logic:equal>--%>
                    <logic:notEqual value="-2" name="QuotationForm" property="endCustomerId">
                        <td class='NArialL' bgcolor='#FFFFEE'><bean:write name="QuotationForm" property="endCustomer"  /></td>
                    </logic:notEqual>
                    <%--<logic:equal value="-2" name="QuotationForm" property="odmId">
                        <td class='NArialL' bgcolor='#FFFFEE'><bean:write name="QuotationForm" property="newEndCustomerName" /></td>
                    </logic:equal>--%>
                    <logic:notEqual value="-2" name="QuotationForm" property="odmId">
                        <td class='NArialL' bgcolor='#FFFFEE'><bean:write name="QuotationForm" property="odm" /></td>
                    </logic:notEqual>
                 </tr>
<%--
                <tr>
                    <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.endCustomer"/> </td>
                    <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.endUser"/></td>
                </tr>
                <tr>
                    <td class='NArialL' bgcolor='#FFFFEE'>&nbsp;<nested:write property="odm"/></td>
                    <td class='NArialL' bgcolor='#FFFFEE'>&nbsp; <nested:write property="endCustomer"/></td>
                </tr>
                <tr>
                    <td class='NArialL' bgcolor='#FFFFEE'>&nbsp;<nested:write property="newEndUserName"/></td>
                    <td class='NArialL' bgcolor='#FFFFEE'>&nbsp; <nested:write property="newEndCustomerName"/></td>
                </tr>
--%>
            </table>

        </td>
        <td colspan="4" align="right" width="65%">
            <table width="40%" border="1" align="right" bordercolor='#000000'  cellspacing='0' cellpadding='0'>
                <tr>
                    <td width="62%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height="1"></td>
                    <td width="38%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height="1"></td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Sub Total</td>
                    <td bgcolor='#DEE1E2' class="NArialL"  align="right"><nested:write property="finalSubTotalAsString"/>&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Sales Tax</td><td bgcolor='#DEE1E2'  class="NArialL" align="right"><nested:write property="finalSalesTaxAsString"/>&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Freight</td><td bgcolor='#DEE1E2'  class="NArialL" align="right"><nested:write property="frieghtAsString"/>&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL"><nested:write property="miscName"/></td><td class="NArialL" bgcolor='#DEE1E2' align="right"><nested:write property="miscAsString"/>&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Balance Due</td><td class="NArialL" bgcolor='#DEE1E2' align="right"><nested:write property="finalOrderTotalAsString"/>&nbsp;</td>
                </tr>

            </table>
        </td>
    </tr>
    </nested:nest>
</table>
</p>
<p STYLE="page-break-after: always"></p>
<p STYLE="page-break-after: always"></p>
<table width="98%" bordercolor='#000000' border='0' cellspacing='0' cellpadding='0' align="center">
    <TR>
        <TD width='100%' valign='top'><img src='<%=chipTracContext%>/jsp/includes/images/Terms and Condition of Sale.jpg' width='1000'/></TD>
    </TR>
</table>
<html:hidden name="approverQuotationForm" property="quotationId"/>
</html:form>
<% } else { %>
<table cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
    <tr>
        <td>
            <table align="center" border="0" width="40%" bgcolor="#FDF5E6">
                <tr><td>&nbsp;</td></tr>
                <tr><td align="center" ><font class="NArialL" ><font color="red">Session has been time out , Please close this window and login again.</font></font></td></tr>
                <tr><td>&nbsp;</td></tr>
                <tr><td align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></td></tr>
            </table>
        </td>
   </tr>
   <tr><td>&nbsp;</td></tr>
</table>
<% } %>
</html:html>
<!-- till here -->
</BODY>
</HTML>
